<template>
  <div
    class="home-body-container animate__animated"
    :class="[visible ? 'animate__zoomIn' : 'animate__zoomOut']"
  >
    <div
      :class="`menu-card ${item.show ? 'mouse-' + item.id : ''}`"
      v-for="item in menuList"
      :key="item.id"
      @mouseenter="handleMouseUserOver(item)"
      @mouseleave="handleMouseOut(item)"
      @click="parentMenuClick(item)"
    >
      <div class="card-icon"></div>
      <div class="card-name">{{ item.name }}</div>
      <div
        :class="
          `station  ${item.show && item.childs.length > 0 ? 'amint' : ''}`
        "
      >
        <div class="suspended-menu">
          <div
            class="menu-item"
            v-for="v in item.childs"
            :key="v.id"
            @click.stop="menuClick(v)"
          >
            <div class="menu-icon"></div>
            <div>{{ v.name }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
/**
 * @Description: 首页
 * @Author: zhailei
 *
 * **/
export default {
  name: "Home",
  props: {
    visible: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      menuList: [
        {
          id: 1,
          name: "基建板块介绍",
          show: false,
          childs: [
            {
              id: "EnterpriseType.01",
              name: "集团概况",
              path: "/system/portal/index",
            },
            {
              id: "EnterpriseType.02",
              name: "工程施工",
              path: "/system/portal/index",
            },
            {
              id: "EnterpriseType.03",
              name: "技术研发",
              path: "/system/portal/index",
            },
            {
              id: "EnterpriseType.04",
              name: "全过程咨询",
              path: "/system/portal/index",
            },
            {
              id: "EnterpriseType.05",
              name: "房地产开发",
              path: "/system/portal/index",
            },
          ],
        },
        { id: 2, name: "基建板块数据看板", show: false, childs: [] },
        { id: 3, name: "港区数字孪生", show: false, childs: [] },
        {
          id: 4,
          name: "扩展系统",
          show: false,
          childs: [],
        },
      ],
    };
  },
  mounted() {},
  methods: {
    parentMenuClick(item = {}) {
      let { id } = item;
      switch (id) {
        //工程项目管理
        case 2:
          this.$parent.handleActive("EngineeringManage");
          break;
        //港区数字孪生
        case 3:
          this.$parent.handleActive("GIS");
          break;
        //扩展系统
        case 4:
          this.$parent.handleActive("extendSystem");
          break;

        default:
          break;
      }
    },
    //系统跳转-进入公司简介页面
    menuClick(menu = {}) {
      this.$emit("onMenu", menu);
      let { id } = menu;
      if (id == "EnterpriseType.01") {
        this.$parent.handleActive("GroupProfile");
      } else {
        this.$parent.handleActive("CompanyProfile");
      }
    },
    //鼠标移入
    handleMouseUserOver(item) {
      let { menuList } = this;
      let newTodos = menuList.map((v) => {
        if (v.id == item.id) {
          v.show = true;
        }
        return v;
      });
      this.menuList = newTodos;
    },
    //鼠标移除
    handleMouseOut(item) {
      let { menuList } = this;
      let newTodos = menuList.map((v) => {
        if (v.id == item.id) {
          v.show = false;
        }
        return v;
      });
      this.menuList = newTodos;
    },
  },
};
</script>
<style lang="less" scoped>
.home-body-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  .menu-card {
    cursor: pointer;
    width: 276px;
    height: 344px;
    margin-right: 72px;
    position: relative;
    &:last-of-type {
      margin-right: 40px;
    }
    box-sizing: border-box;
    padding: 50px 0;
    .card-icon {
      height: 176px;
      width: 176px;
      position: relative;
      left: 50%;
      transform: translateX(-50%);
    }
    .card-name {
      margin-top: 30px;
      text-align: center;
      font-size: 24px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: #f9f7fe;
    }
    .station {
      height: 240px;
      width: 260px;
      position: absolute;
      left: 8px;
      bottom: 0px;
      box-sizing: border-box;
      padding-top: 48px;
      opacity: 0;
      transition: 0.5s;
      &.amint {
        bottom: -200px;
        opacity: 1;
        transition: 0.5s;
      }
      .suspended-menu {
        width: 100%;
        border-radius: 4px;
        background: rgba(0, 81, 97, 0.8);
        box-sizing: border-box;
        padding: 10px 20px;
        .menu-item {
          height: 40px;
          font-size: 18px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #dddddd;
          text-align: center;
          display: flex;
          align-items: center;
          box-sizing: border-box;
          padding-left: 47px;
          margin-bottom: 8px;
          .menu-icon {
            flex-shrink: 0;
            width: 16px;
            height: 18px;
            margin-right: 16px;
          }
          &:hover {
            background: rgba(23, 195, 229, 0.8);
            border-radius: 4px;
            color: #ffffff;
            transition: 0.8s;
          }
        }
      }
    }
    &:nth-child(1) {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_1.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_icon_1.png);
        background-size: 100% 100%;
      }
      .station {
        .suspended-menu {
          .menu-item {
            &:nth-child(1) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_9.png);
                background-size: 100% 100%;
              }
            }
            &:nth-child(2) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_1.png);
                background-size: 100% 100%;
              }
            }
            &:nth-child(3) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_2.png);
                background-size: 100% 100%;
              }
            }
            &:nth-child(4) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_3.png);
                background-size: 100% 100%;
              }
            }
            &:nth-child(5) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_4.png);
                background-size: 100% 100%;
              }
            }
          }
        }
      }
    }
    &:nth-child(2) {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_2.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_icon_2.png);
        background-size: 100% 100%;
      }
    }
    &:nth-child(3) {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_3.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_icon_3.png);
        background-size: 100% 100%;
      }
    }
    &:nth-child(4) {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_4.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_icon_4.png);
        background-size: 100% 100%;
      }
      .station {
        .suspended-menu {
          .menu-item {
            &:nth-child(1) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_5.png);
                background-size: 100% 100%;
              }
            }
            &:nth-child(2) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_6.png);
                background-size: 100% 100%;
              }
            }
            &:nth-child(3) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_7.png);
                background-size: 100% 100%;
              }
            }
            &:nth-child(4) {
              .menu-icon {
                background: url(~@/assets/img/portalEntry/menu_icon_8.png);
                background-size: 100% 100%;
              }
            }
          }
        }
      }
    }

    &.mouse-1 {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_active.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_active_icon_1.png);
        background-size: 100% 100%;
      }
    }
    &.mouse-2 {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_active.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_active_icon_2.png);
        background-size: 100% 100%;
      }
    }
    &.mouse-3 {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_active.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_active_icon_3.png);
        background-size: 100% 100%;
      }
    }
    &.mouse-4 {
      transition: 0.5s;
      background: url(~@/assets/img/portalEntry/card_active.png);
      background-size: 100% 100%;
      .card-icon {
        transition: 0.5s;
        background: url(~@/assets/img/portalEntry/card_active_icon_4.png);
        background-size: 100% 100%;
      }
    }
  }
}
</style>
